# 使用腾讯云镜像加速地址拉取 Node.js 镜像
FROM 	dockertest.jsdelivr.fyi/library/node:22.18.0 AS builder

# 设置工作目录
ENV WORKDIR=/soybean-admin
WORKDIR $WORKDIR

# 复制项目文件到工作目录
COPY ./ $WORKDIR/

# 设置构建参数和环境变量
ARG version
ENV COMMITID=$version

# 安装 pnpm 并构建项目
RUN npm i -g pnpm@8.7.6
RUN pnpm install
RUN pnpm build:no-check

# 使用腾讯云镜像加速地址拉取 Nginx 镜像
FROM dockertest.jsdelivr.fyi/library/nginx:alpine AS prod

# 创建目录并复制构建结果
RUN mkdir /soybean
COPY --from=builder /soybean-admin/dist /soybean-admin
COPY --from=builder /soybean-admin/docker/nginx.conf /etc/nginx/nginx.conf

# 暴露端口
EXPOSE 80
